package dao.oc_property;

import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import entitybean.oc_property.EntityBean_Oc_Property;

public class DaoImpl_Oc_Property extends HibernateDaoSupport implements
		Dao_Oc_Property {
	public void Insert_Oc_Property(EntityBean_Oc_Property e) {
		this.getHibernateTemplate().save(e);
	}

	public void Update_Oc_Property(EntityBean_Oc_Property e) {
		this.getHibernateTemplate().update(e);
	}

	public void Delete_Oc_Property(EntityBean_Oc_Property e) {
		this.getHibernateTemplate().delete(e);
	}

	@SuppressWarnings("unchecked")
	public void Delete_Oc_Property(String id) {
		List<EntityBean_Oc_Property> list = this.getHibernateTemplate().find(
				"from EntityBean_Oc_Property where del='OFF' and id in(" + id
						+ ")");
		for (int i = 0; i < list.size(); i++) {
			EntityBean_Oc_Property e = list.get(i);
			e.setDel("ON");
			this.getHibernateTemplate().update(e);

		}

	}

	@SuppressWarnings("unchecked")
	public List<EntityBean_Oc_Property> Find_EntityBean_Oc_Property_by_property_kind(
			Integer id) {
		return this.getHibernateTemplate().find(
				"from EntityBean_Oc_Property where kind_id=" + id
						+ " and del='OFF'");

	}
	public EntityBean_Oc_Property Find_EntityBean_Oc_Property_By_Id(String id)
	{
		EntityBean_Oc_Property e=new EntityBean_Oc_Property();
		List<EntityBean_Oc_Property>list=this.getHibernateTemplate().find("from EntityBean_Oc_Property where id="+id);
		if(list.size()>0)
		{
			e=list.get(0);
		}
		return e;
		
		
	}
}
